var url = 'ws://localhost:8999/ws';

function connect (user, func) {
 
  var connurl  = url+"?uid="+user.uid+"&pwd="+user.pwd+"&uname="+user.nickName+"&rid="+user.rid;
   console.log("websocket 链接url"+connurl);
  wx.connectSocket({
    url: connurl
  });

  wx.onSocketMessage(func);
}


function send (typeMsg,msg) {
  var data = {type:typeMsg,data:msg};
  console.log(JSON.stringify(data));
  wx.sendSocketMessage({data:JSON.stringify(data)});
}
module.exports = {
  connect: connect,
  send : send
}
